const state = {
  curComponent: "detail1",
  active: 1, // 1 训练员 2 教练员 3 管理员
  trainList: [
    {
      ID: "1",
      Img: "a.jpg",
      Name: "gray",
      Age: "24",
      Level: "2",
    },
  ],
  coachList: [],
  adminList: [],
  choiceUser: null,
};

const mutations = {
  train_list(state, list) {
    state.trainList = list;
  },
  coach_list(state, list) {
    state.coachList = list;
  },
  admin_list(state, list) {
    state.adminList = list;
  },
  change_cur_component(state, type) {
    state.curComponent = "detail" + type;
    state.active = type;
  },
  choice_user(state, user) {
    state.choiceUser = user;
  },
};

const actions = {
  /**
   * @param {Array} list
   * @param {Number} type  Train  训练员  Coach 教练员  Admin  管理员
   */
  getUserList({ commit }, { list, defaultRow, type }) {
    let _type = 0;
    list = list || [];
    if (type == "Train") {
      commit("train_list", list);
      _type = 1;
    } else if (type == "Coach") {
      commit("coach_list", list);
      _type = 2;
    } else {
      commit("admin_list", list);
      _type = 3;
    }
    commit("change_cur_component", _type);
    commit("choice_user", null);
  },
  choiceUser({ commit }, { user }) {
    commit("choice_user", user);
  },
  getTrainList({ commit }, name) {},
  getCoachList({ commit }, name) {},
  getAdminList({ commit }, name) {},
};

const getters = {};

export default {
  state,
  mutations,
  actions,
  getters,
};
